﻿using System;

    class DancingBits
    {
        static void Main()
        {
            uint K = uint.Parse(Console.ReadLine());
            uint N = uint.Parse(Console.ReadLine());
            uint inputer;
            uint onecounter = 0;
            uint zerocounter = 0;
            uint dancers = 0;
            uint[] array = new uint[N];
            uint bin=0;
            for (uint counter = 0; counter < N; counter++)
            {
                inputer =uint.Parse( Console.ReadLine());
                array[counter] = inputer;
            }
            for (uint counter = 0; counter < array.Length; counter++)
            {
                bin = array[counter];
                while (bin > 0)
                {
                    if (bin % 2 == 0)
                    {
                        zerocounter++;
                        onecounter = 0;
                    }
                    if (bin % 2 == 1)
                    {
                        onecounter++;
                        zerocounter = 0;
                    }
                    if ((zerocounter == K))
                    {                        
                        dancers++;
                        zerocounter = 0;
                      
                    }
                    if ((onecounter == K))
                    {
                        
                        dancers++;
                        onecounter = 0;
                    }
                    bin /= 2;
                }
            }
            Console.WriteLine(dancers);
        }
    }

